<template>
  <div class="search-bar">
    <el-form :inline="true" :model="formItem" class="form-filter" size="mini">
      <el-form-item>
        <el-select v-model="inst" placeholder="请选择厅局" clearable filterable style="width:100%" @change="localSearch">
          <el-option v-for="(item) in insts" :key="item.code" :label="item.name" :value="item.code" />
        </el-select>
      </el-form-item>
      <!-- <el-form-item>
        <el-input
          v-model="formItem.s_name"
          clearable
          placeholder="请输入小组名称..."
          @keyup.enter.native="search"
          @change="search"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button plain icon="el-icon-search" @click="search" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

// 定义一个查询表单原始项
const formItem = {
  s_name: ''
}

export default {
  name: 'OperationGroupTableFilter',

  data() {
    return {
      formItem: {
        ...formItem
      },
      inst: ''
    }
  },
  computed: {
    insts: function() {
      return this.$attrs.insts
    }
  },
  methods: {
    // 查询按钮点击事件处理
    search: function() {
      this.$parent.filter(this.formItem)
    },
    // 重置按钮点击事件处理
    reset: function() {
      this.formItem = {
        ...formItem
      }
      this.search()
    },
    localSearch: function(val) {
      this.$parent.localSearch(val)
    }
  }
}
</script>
